//
//  XDSCatalogueTabBarController.m
//  XDSReader
//
//  Created by dusheng.xu on 2017/6/20.
//  Copyright © 2017年 macos. All rights reserved.
//

#import "XDSCatalogueTabBarController.h"
#import "XDSCatalogueViewController.h"
#import "XDSNoteViewController.h"
#import "XDSMarkViewController.h"
#import "XDSReadViewConst.h"
@interface XDSCatalogueTabBarController ()
@property (strong, nonatomic) XDSCatalogueViewController *catalogueVC;
@property (strong, nonatomic) XDSNoteViewController *noteVC;
@property (strong, nonatomic) XDSMarkViewController *markVC;

@end

@implementation XDSCatalogueTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = AppBgThemeColor;
    _catalogueVC = [[XDSCatalogueViewController alloc] initWithStyle:UITableViewStyleGrouped];
    _catalogueVC.title = NSLocalizedString(@"目录", nil);
    
    _noteVC = [[XDSNoteViewController alloc] initWithStyle:UITableViewStyleGrouped];
    _noteVC.title = NSLocalizedString(@"笔记", nil);
    
    _markVC = [[XDSMarkViewController alloc] initWithStyle:UITableViewStyleGrouped];
    _markVC.title = NSLocalizedString(@"书签", nil);
    
    self.viewControllers = @[_catalogueVC, _noteVC, _markVC];
    self.tabBar.translucent = NO;
    self.tabBar.barTintColor = READ_BACKGROUND_COLOC;
    [[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
    [[UITabBar appearance] setBackgroundColor:READ_BACKGROUND_COLOC];
    [[UITabBar appearance] setShadowImage:[[UIImage alloc] init]];
    for (UITabBarItem *item in self.tabBar.items) {
        [item setTitlePositionAdjustment:UIOffsetMake(0, -13)];
        [item setTitleTextAttributes:@{
            NSFontAttributeName:[UIFont systemFontOfSize:13],
            NSForegroundColorAttributeName:[UIColor whiteColor]
        }
                            forState:UIControlStateNormal];
        [item setTitleTextAttributes:@{
            NSFontAttributeName:[UIFont systemFontOfSize:13],
            NSForegroundColorAttributeName:[CommUtls colorWithHexString:@"#FDAD35"]
        }
                            forState:UIControlStateSelected];
    }
}
- (void)dealloc
{
    [[UITabBar appearance] setBackgroundImage:[[UIImage alloc] init]];
    [[UITabBar appearance] setBackgroundColor:APPTabBarThemeColor];
    [[UITabBar appearance] setShadowImage:[UIImage imageNamed:@"tapbar_top_line"]];
    NSLog(@"dealloc----%@",@"XDSCatalogueTabBarController");
}

- (void)setCvDelegate:(id<XDSCatalogueViewDelegate>)cvDelegate{
    _cvDelegate = cvDelegate;
    _catalogueVC.cvDelegate = _cvDelegate;
    _noteVC.cvDelegate = _cvDelegate;
    _markVC.cvDelegate = _cvDelegate;
}

- (void)refreshData{
    [_noteVC refreshData];
    [_markVC refreshData];
}

@end
